package com.service.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.service.dao.dto.rep.FundTopUpForDayReq;
import com.service.dao.model.Member;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年09月19日</dd>
 * </dl>
 *
 * @author
 */
public interface MemberMapper extends BaseMapper<Member> {

    List<Member> selectByAccount(@Param("userAccount") String userAccount, @Param("userStatus") Integer userStatus);

    int updateMemberStatus2Invalid(@Param("idList") List<Integer> idList);

    List<String> selectAccountByIds(@Param("ids") List<Integer> ids);

    @Select("select * from hm_member where id = (select pid from hm_member where id = #{memberId})")
    Member getMemberTop1(@Param("memberId") Integer memberId);

    @Select("select * from hm_member where id = #{memberId}")
    Member getMemberById(@Param("memberId") Integer memberId);

    @Select("select * from hm_member where id = (select gid from hm_member where id = #{memberId})")
    Member getMemberTop2(@Param("memberId") Integer memberId);

    /**
     * 获取会员的有效推荐会员数
     *
     * @param memberId
     * @param memberGrade
     * @return
     */
    Integer countValidMemberByPath(@Param("memberId") Integer memberId, @Param("memberGrade") Integer memberGrade);

    /**
     * 获取会员的有效推荐会员数
     *
     * @param memberId
     * @param memberGrade
     * @return
     */
    List<Integer> listValidMemberByPath(@Param("memberId") Integer memberId, @Param("memberGrade") Integer memberGrade);

    /**
     * 获取会员的有效推荐会员列表
     *
     * @param memberId
     * @param memberGrade
     * @return
     */
    List<Member> listEffectInviteMemberByPath(@Param("memberId") Integer memberId, @Param("memberGrade") Integer memberGrade);

    /**
     * 获取会员的某个星级下的直推荐会员数
     *
     * @param memberId
     * @param memberGrade
     * @return
     */
    Integer countByParentIdAndStarGrade(@Param("memberId") Integer memberId, @Param("memberGrade") List<Integer> memberGrade);

    /**
     * 获取最大会员等级
     *
     * @param userStatus
     * @param active
     * @return
     */
    Integer getMaxVipGrade(@Param("userStatus") Integer userStatus, @Param("active") Integer active);

    List<Integer> listMemberIdsByParam(@Param("mobile") String mobile, @Param("userName") String userName);

    /**
     * 获取所有状态的用户id列表
     *
     * @param userStatus
     * @return
     */
    @Select("select id from hm_member where user_status = #{userStatus}")
    List<Integer> listAllMemberIdsByStatus(@Param("userStatus") Integer userStatus);

    /**
     * 获取当前用户的直推用户ID列表
     *
     * @param userStatus
     * @return
     */
    @Select("select id from hm_member where pid = #{memberId} and user_status = #{userStatus}")
    List<Integer> listMemberDirectInvitationIdsByParam(@Param("memberId") Integer memberId, @Param("userStatus") Integer userStatus);


    /**
     * 获取当前用户的间推用户ID列表 第二层
     *
     * @param memberId
     * @param userStatus 用户状态
     * @return
     */
    @Select("select id from hm_member where gid = #{memberId} and user_status = #{userStatus}")
    List<Integer> listMemberIndirectInvitationIdsByParam(@Param("memberId") Integer memberId, @Param("userStatus") Integer userStatus);

    /**
     * 查询当前用户下属的团队用户
     *
     * @param memberId
     * @return
     */
    List<Integer> listByCurrentMemberPath(@Param("memberId") Integer memberId, @Param("userStatus") Integer userStatus);

}
